#!/usr/bin/python3
# -*- coding:UTF-8 -*-
'''Module DocString'''

__author__ = 'Wang Zhe'

import re


def print_msg_with_user(origin, user, email_name, email_domain):
    """Function DocString"""
    if user is None:
        print("匹配失败！\n")
    else:
        print("匹配成功：%s,user:%s,email_name:%s,email_domain:%s" %
              (origin, user, email_name, email_domain))


def print_msg(origin, email_name, email_domain):
    """Function DocString"""
    if email_name is None:
        print("匹配失败！\n")
    else:
        print("匹配成功：%s,email_name:%s,email_domain:%s" %
              (origin, email_name, email_domain))


def main():
    '''Func DocString'''
    re_mail = re.compile(r'(^.+)\@(\w+\.[a-zA-Z]{3}$)')
    ret = re_mail.match('someone@gmail.com')
    print_msg(ret.group(), ret.group(1), ret.group(2))
    ret = re_mail.match('bill.gates@microsoft.com')
    print_msg(ret.group(), ret.group(1), ret.group(2))
    re_mail = re.compile(r'^\<(.+)\>\s*(.+)@(\w+\.[a-zA-Z]{3})')
    ret = re_mail.match('<Tom Paris> tom@voyager.org')
    print_msg_with_user(ret.group(), ret.group(1), ret.group(2), ret.group(3))


if __name__ == '__main__':
    main()
